<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    function deleteMiddle(head) {
      if (!head.next) return null

      let runner = head, mid = head, prev = null

      while (runner && runner.next) {
        prev = mid
        mid = mid.next
        runner = runner.next.next
      }

      prev.next = prev.next.next

      return head
    };
    console.log(deleteMiddle([1, 2, 3, 4, 5]
    ));
  </script>
</body>

</html>